﻿
using D.Medicalcare.ErrorCode;
using D.Medicalcare.Write.API.Application.Commands.MenuCommand;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace D.Medicalcare.Write.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class MenuController : ControllerBase
    {
        private readonly IMediator mediator;

        public MenuController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 菜单添加
        /// </summary>
        /// <param name="request">命令</param>
        /// <returns>APIResult</returns>
        [HttpPost]
        public Task<APIResult<int>> AddMenu(AddMenuCommand request)
        {
            return mediator.Send(request);

        }
        /// <summary>
        /// 菜单删除
        /// </summary>
        /// <param name="request">命令</param>
        /// <returns>APIResult</returns>
        [HttpPost]
        public async Task<APIResult<object>> DelsMenu([FromQuery] DelsMenuCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 角色菜单添加
        /// </summary>
        /// <param name="request">命令</param>
        /// <returns>APIResult</returns>
        [HttpPost]
        public async Task<APIResult<int>> AddRMC(AddRMCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 角色菜单删除
        /// </summary>
        /// <param name="request">命令</param>
        /// <returns>APIResult</returns>
        [HttpPost]
        public async Task<APIResult<int>> DelRoleMenu([FromQuery] DelRoleMenuCommand request)
        {
            return await mediator.Send(request);
        }


    }
}
